<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>赞(0)</button>
    <button>赞(0)</button>
    <button>赞(0)</button>
    <button>赞(0)</button>

    <script>
        //闭包缓存数据
        function getValue() {
            var value = 1;
            return function() {
                this.innerHTML = "赞(" + (value++) + ")";
            }
        }
        var btn = document.getElementsByTagName('button');
        for (var i = 0; i <= btn.length; i++) {
            btn[i].onclick = getValue();
        }
    </script>
</body>

</html>